<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<form:form commandName="databean" cssClass="form-horizontal" role="form" onsubmit="false">
	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title">基本信息</h3>
		</div>
		<div class="panel-body">
			<div class="col-sm-12">
				<div class="form-group">

					<label class="col-sm-2 control-label no-padding-right" for="goodName">商品名称<font color="red">*</font></label>
					<div class="col-sm-3">
						<input type="text" name="goodName" id="goodName" placeholder="请输入商品名称" value="${databean.goodName}" class="form-control required">
					</div>

					<label class="col-sm-2 control-label no-padding-right" for="price">价格<font color="red"></font></label>
					<div class="col-sm-3">
						<input type="text" name="price" id="price"  placeholder="请设置价格" value="${databean.price}" class="form-control required">
					</div>
				</div>

				<div class="form-group">

					<label class="col-sm-2 control-label no-padding-right" for="inventory">库存<font color="red">*</font></label>
					<div class="col-sm-3">
						<input type="text" name="inventory" id="inventory" placeholder="请输入库存" value="${databean.inventory}" class="form-control required">
					</div>


					<label class="col-sm-2 control-label no-padding-right" for="inventory">销量<font color="red">*</font></label>
					<div class="col-sm-3">
						<input type="text" name="salesVolume" id="salesVolume" placeholder="销量不可设置" readonly="readonly" value="${databean.salesVolume}" class="form-control ">
					</div>

				</div>

				<div class="form-group">
					<label class="col-sm-2 control-label no-padding-right" for="intro">简介<font color="red"></font></label>
					<div class="col-sm-8">
						<input type="text" name="intro" id="intro"  placeholder="请输入商品简介" value="${databean.intro}" class="form-control required ">
					</div>

<%--
					<label class="col-sm-2 control-label no-padding-right" for="image">简介<font color="red"></font></label>
					<div class="col-sm-3">
						<input type="text" name="image" id="image" readonly="readonly" placeholder="价格" value="${databean.image}" class="form-control ">
					</div>--%>
				</div>



				<div class="form-group">
					<label class="col-sm-2 control-label no-padding-right" for="claId">商品分类</label>
					<div class="col-sm-3">
						<form:select path="brandId" items="${classes}" itemValue="sysId" itemLabel="claName" cssClass="form-control"></form:select>
					</div>

					<label class="col-sm-2 control-label no-padding-right" for="claId">品牌分类</label>
					<div class="col-sm-3">	
						<form:select path="claId" items="${brands}" itemValue="sysId" itemLabel="brandName" cssClass="form-control"></form:select>
					</div>



					<%--<label class="col-sm-2 control-label no-padding-right" for="roleId">角色</label>
					<div class="col-sm-3">
						<form:select path="roleId" items="${redis:getDictList('Position',false)}" itemValue="basId" itemLabel="name" cssClass="form-control"></form:select>
					</div>--%>
				</div>

			</div>
		</div>
	</div>
</form:form>
		<script type="text/javascript">
			jQuery(function($) {
				$('.date-picker').datepicker({
					inline: true,
					format:"yyyy-mm-dd",
					autoclose: true,
					todayHighlight: true,
					language: 'cn'
				})
				//show datepicker when clicking on the icon
				.next().on(ace.click_event, function(){
					$(this).prev().focus();
				});

				$("#uploadBtn").click(function () {
					console.log("kaishile==============")
					var fileinp= $('#fileimg')[0];
					var file = fileinp.files[0];
					var formData = new FormData();
					console.log("fileinp",fileinp);
					console.log("file",file);
					console.log("formData",formData);
					if(file){
						formData.append('files',file);
						console.log("data",formData);

						$.ajax({
							url:'/pictureUpload/uploadBatch',
							type:'POST',
							data: formData,
							contentType: false, // 必须false才会自动加上正确的Content-Type
							processData: false, // 必须false才会避开jQuery对formdata的默认处理
							cache: false,
							success: function(data) {
								// 上传成功后的处理
								console.log(data.data);
								$("#image").attr("value",data.data[0].sysId);
								console.log("fileImg's value",$("#image").val())
								alert(data.data);
							},
						})

					}else {
						console.log("没有文件")
					}

				})
		/*		$("#uploadBtn").click(function() {
					console.log("kaishile==============")
					var formData = new FormData($('#fileimg')[0]); // 使用 FormData 对象包装表单数据
					console.log("file",formData)
					$.ajax({
						url:'/pictureUpload/uploadBatch',
						type:post,
						data: formData,
						contentType: false, // 必须false才会自动加上正确的Content-Type
						processData: false, // 必须false才会避开jQuery对formdata的默认处理
						success: function(data) {
							// 上传成功后的处理
							console.log(data);
							alert('Upload success!');
						},
					})
				});*/

			});

		/*	jQuery(function ($) {

				$("#uploadBtn").click(function() {
					console.log("kaishile==============")
					var formData = new FormData($('#fileimg')[0]); // 使用 FormData 对象包装表单数据
					console.log("file",formData)
					$.ajax({
						url:'/pictureUpload/uploadBatch',
						type:post,
						data: formData,
						contentType: false, // 必须false才会自动加上正确的Content-Type
						processData: false, // 必须false才会避开jQuery对formdata的默认处理
						success: function(data) {
							// 上传成功后的处理
							console.log(data);
							alert('Upload success!');
						},
					})
				});
			})
*/






		</script>